function sample_one_video_weight(video_index_begin, video_index_end, training)    
    if (ischar(video_index_begin)), video_index_begin = ...
            str2num(video_index_begin), end;
        if (ischar(video_index_end)), video_index_end = ...
                str2num(video_index_end), end;        
    if (ischar(training)), training = str2num(training), end;
    load data_config
    if (training==1)
        file_name_out = sprintf('features/sampled_patch_train_weight_%02d',video_index_begin);
        file_name_integral = sprintf('features/integral_train_%02d', ...
                                    video_index_begin);        
    else        
        file_name_out = sprintf('features/sampled_patch_test_weight_%02d',video_index_begin);
        file_name_integral = sprintf('features/integral_train_%02d', ...
                                    video_index_begin);        
    end 
    file_name_integral
    load(file_name_integral);
    num_sub_blocks = 4;
    sampled_patches = zeros(num_sub_blocks,video_index_end- video_index_begin +1, num_samples);
    for video_index= video_index_begin:video_index_end        
        integral = reshape(integral_all(video_index-video_index_begin+1, :, :), ...
                           [size(integral_all,2) size(integral_all,3)]);
        for sample = 1:num_samples
            lower_x = grids(1, sample);
            higher_x = grids(2, sample);
            lower_y = grids(3, sample);
            higher_y = grids(4, sample);
            mid_x = floor((lower_x + higher_x)/2);
            mid_y = floor((lower_y + higher_y)/2);            
            %blocks = img_current(lower_y:higher_y,lower_x:higher_x);        
            %blocks_temp = blocks(1:end);
            %blocks_sum = sum(blocks_temp);            
            blocks_sum(1) = compute_sum_from_integral(integral, ...
                                                      higher_y, ...
                                                      mid_y, higher_x, ...
                                                      mid_x);
            blocks_sum(2) = compute_sum_from_integral(integral, ...
                                                      mid_y-1, ...
                                                      lower_y, higher_x, ...
                                                      mid_x);
            blocks_sum(3) = compute_sum_from_integral(integral, ...
                                                      higher_y, ...
                                                      mid_y, mid_x-1, ...
                                                      lower_x);
            blocks_sum(4) = compute_sum_from_integral(integral, ...
                                                      mid_y-1, ...
                                                      lower_y, mid_x-1, ...
                                                      lower_x);            
            sampled_patches(:, video_index-video_index_begin+1,sample) =  blocks_sum;
        end    
    end
    save(file_name_out, 'sampled_patches');
end
